xen: arm: TCR_EL1 is 64-bit on arm64
authorIan Campbell <ian.campbell@citrix.com>
Tue, 3 Dec 2013 15:13:36 +0000 (15:13 +0000)
committerIan Campbell <ian.campbell@citrix.com>
Wed, 4 Dec 2013 14:32:19 +0000 (14:32 +0000)
Storing it in a 32-bit variable in struct arch_vcpu caused breakage over
context switch.

There were also several other places which stored this as the 32-bit value.
Update them all.

The "struct vcpu_guest_context" case needs special consideration. This struct
is in theory is exposed to guests, via the VCPUOP_initialise hypercall.
However as discussed in
http://lists.xen.org/archives/html/xen-devel/2013-10/msg00912.html this isn't
really a guest visible interface since ARM uses PSCI for VCPU bringup
(VCPUOP_initialise simply isn't available) The other users of this interface
are the domctls, which are not a stable API. Therefore while fixing the ttbcr
size also surround the struct in ifdefs to restrict the struct to the
hypervisor and the tools only (omitting the extra complexity of renaming as I
suggested in the referenced thread).

NB TCR_EL1 on arm64 is known as TTBCR on arm32, hence the apparent naming
inconsistencies.

Spotted-by: Pranavkumar Sawargaonkar <pranavkumar@linaro.org>
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Pranavkumar Sawargaonkar <pranavkumar@linaro.org>
Cc: Anup Patel <anup.patel@linaro.org>
Cc: patches@linaro.org
Cc: patches@apm.com
tools/include/xen-foreign/reference.size
tools/xentrace/xenctx.c
xen/arch/arm/traps.c
xen/include/asm-arm/domain.h
xen/include/public/arch-arm.h

index b3347b434cb917e580e0a86e20c4fb48444e0383..60ee2621430883221e9d4ea0cb0642123dad886c 100644 (file)
@@ -5,7 +5,7 @@ start_info                |       -       -    1112    1168
 trap_info                 |       -       -       8      16
 cpu_user_regs             |       -       -      68     200
 vcpu_guest_core_regs      |     304     304       -       -
-vcpu_guest_context        |     336     336    2800    5168
+vcpu_guest_context        |     344     344    2800    5168
 arch_vcpu_info            |       0       0      24      16
 vcpu_time_info            |      32      32      32      32
 vcpu_info                 |      48      48      64      64
index ba502fd5dcaf4aac9de73d63eb5a219604984ddd..7275a00eb8ed8d305f7af3efdd89b33012e3928d 100644 (file)
@@ -578,7 +578,7 @@ static void print_ctx(vcpu_guest_context_any_t *ctx_any)
 #endif
 
     printf("SCTLR: %08"PRIx32"\n", ctx->sctlr);
-    printf("TTBCR: %08"PRIx32"\n", ctx->ttbcr);
+    printf("TTBCR: %016"PRIx64"\n", ctx->ttbcr);
     printf("TTBR0: %016"PRIx64"\n", ctx->ttbr0);
     printf("TTBR1: %016"PRIx64"\n", ctx->ttbr1);
 }
index 8144b2b52dbd1550b8676637e786cf0f859f614d..458128ef5ae7b4d7e3304452e8865a493f4ee2bc 100644 (file)
@@ -330,7 +330,8 @@ static void inject_undef64_exception(struct cpu_user_regs *regs, int instr_len)
 
 struct reg_ctxt {
     /* Guest-side state */
-    uint32_t sctlr_el1, tcr_el1;
+    uint32_t sctlr_el1;
+    register_t tcr_el1;
     uint64_t ttbr0_el1, ttbr1_el1;
 #ifdef CONFIG_ARM_32
     uint32_t dfsr, ifsr;
@@ -433,7 +434,7 @@ static void show_registers_32(struct cpu_user_regs *regs,
     if ( guest_mode )
     {
         printk("     SCTLR: %08"PRIx32"\n", ctxt->sctlr_el1);
-        printk("       TCR: %08"PRIx32"\n", ctxt->tcr_el1);
+        printk("       TCR: %08"PRIregister"\n", ctxt->tcr_el1);
         printk("     TTBR0: %016"PRIx64"\n", ctxt->ttbr0_el1);
         printk("     TTBR1: %016"PRIx64"\n", ctxt->ttbr1_el1);
         printk("      IFAR: %08"PRIx32", IFSR: %08"PRIx32"\n"
@@ -505,7 +506,7 @@ static void show_registers_64(struct cpu_user_regs *regs,
         printk("   FAR_EL1: %016"PRIx64"\n", ctxt->far);
         printk("\n");
         printk(" SCTLR_EL1: %08"PRIx32"\n", ctxt->sctlr_el1);
-        printk("   TCR_EL1: %08"PRIx32"\n", ctxt->tcr_el1);
+        printk("   TCR_EL1: %08"PRIregister"\n", ctxt->tcr_el1);
         printk(" TTBR0_EL1: %016"PRIx64"\n", ctxt->ttbr0_el1);
         printk(" TTBR1_EL1: %016"PRIx64"\n", ctxt->ttbr1_el1);
         printk("\n");
@@ -1257,14 +1258,14 @@ static void do_sysreg(struct cpu_user_regs *regs,
 
 void dump_guest_s1_walk(struct domain *d, vaddr_t addr)
 {
-    uint32_t ttbcr = READ_SYSREG32(TCR_EL1);
+    register_t ttbcr = READ_SYSREG(TCR_EL1);
     uint64_t ttbr0 = READ_SYSREG64(TTBR0_EL1);
     paddr_t paddr;
     uint32_t offset;
     uint32_t *first = NULL, *second = NULL;
 
     printk("dom%d VA 0x%08"PRIvaddr"\n", d->domain_id, addr);
-    printk("    TTBCR: 0x%08"PRIx32"\n", ttbcr);
+    printk("    TTBCR: 0x%08"PRIregister"\n", ttbcr);
     printk("    TTBR0: 0x%016"PRIx64" = 0x%"PRIpaddr"\n",
            ttbr0, p2m_lookup(d, ttbr0 & PAGE_MASK));
 
index d5cae2eb9489dab34ba2d7415b1ea1dcab152540..8ebee3e05f6f2026ffcc1cdf2fb3977e70810f27 100644 (file)
@@ -165,7 +165,7 @@ struct arch_vcpu
 
     /* MMU */
     register_t vbar;
-    uint32_t ttbcr;
+    register_t ttbcr;
     uint64_t ttbr0, ttbr1;
 
     uint32_t dacr; /* 32-bit guests only */
index cb41ddc4601e1f3f3c4b3922b71fed50259459fe..475cb4aa72eef75c41b83d7bca28f18c8b567fcb 100644 (file)
@@ -278,6 +278,7 @@ typedef uint64_t xen_pfn_t;
 typedef uint64_t xen_ulong_t;
 #define PRI_xen_ulong PRIx64
 
+#if defined(__XEN__) || defined(__XEN_TOOLS__)
 struct vcpu_guest_context {
 #define _VGCF_online                   0
 #define VGCF_online                    (1<<_VGCF_online)
@@ -285,11 +286,12 @@ struct vcpu_guest_context {
 
     struct vcpu_guest_core_regs user_regs;  /* Core CPU registers */
 
-    uint32_t sctlr, ttbcr;
-    uint64_t ttbr0, ttbr1;
+    uint32_t sctlr;
+    uint64_t ttbcr, ttbr0, ttbr1;
 };
 typedef struct vcpu_guest_context vcpu_guest_context_t;
 DEFINE_XEN_GUEST_HANDLE(vcpu_guest_context_t);
+#endif
 
 struct arch_vcpu_info {
 };